<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.project.control.FoodControl"%>
<%@ page import="com.project.control.DateControl"%>
<%@ page import="com.project.model.Food"%>
<%@ page import="com.project.util.*"%>
<html>
	<%
		request.setCharacterEncoding("UTF-8");
		Food food = new Food();

		String title = request.getParameter("title");
		food.setTitle(title);
		System.out.println(title);

		int clicks = 0;
		food.setClicks(clicks);

		String editor = request.getParameter("editor");
		food.setEditor(editor);
		System.out.println(editor);
		
		String original = request.getParameter("original");
		food.setOriginal(original);
		System.out.println(original);

		int type = Integer.parseInt(request.getParameter("type"));
		food.setType(type);
		System.out.println(type);

		String content = request.getParameter("content1");    
		food.setContent(content);
		System.out.println(content);

		String addtime = request.getParameter("addtime");
		food.setAddtime(addtime);
		System.out.println(addtime);
		

	FoodControl hc = new FoodControl();

		if (hc.insertFood(food)) {
			int objectid = hc.getMaxId();
			System.out.println(objectid);
			session.setAttribute("objectid", objectid);
			session.setAttribute("type",type);
		
	%>
	<script language="javascript">
if (window.confirm("录入成功，是否继续录入?"))
	window.location.href = "food_add.jsp";
else
	window.location.href = "food.jsp";
</script>
	<%
		} else {
	%>
	<script language="javascript">
if (window.confirm("录入失败，是否继续录入?"))
	window.location.href = "food_add.jsp";
else
	window.location.href = "food.jsp";
</script>
	<%
		}
	%>
</html>